var fname;
var mname;
var lname;


function $(id){
	return document.getElementById(id);
}

function validate(){
	var fname = $("fname").value;
	var mname = $("mname").value;
	var lname = $("lname").value;
	var submitOK = true;
	var errorString = "Error:\n";
	var characters = "^[a-zA-Z]+$";
	var middleNameCharacters = "^[a-zA-Z]*$";
	
	if(fname == "") {
		errorString = errorString + "First name must be entered\n";
		submitOK = false;
	}
	else if(!fname.match(characters)){
		errorString = errorString + "First name should only contain characters\n";
		submitOK = false;
	}
	
	if(!mname.match(middleNameCharacters)){
		errorString = errorString + "Middle name should only contain characters\n";
		submitOK = false;
	}
	
	if(lname == "") {
		errorString = errorString + "Last name must be entered\n";
		submitOK = false;
	}
	else if(!lname.match(characters)){
		errorString = errorString + "Last name should only contain characters\n";
		submitOK = false;
	}

	if(!submitOK){
		alert(errorString);
		return false; 
	}
}








